package com.ebs.md.fxmonitor.marketmonitor.model;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/fxmonitor/main/src/main/java/com/ebs/md/fxmonitor/marketmonitor/model/OBCRemove.java $
 *  $Revision: #13 $  $Change: 115868 $  $DateTime: 2012/10/17 13:08:52 $  $Author: Arik.Sher $
 */

import com.ebs.md.api.BookSide;
import com.ebs.md.api.IDetailedBookEntry;
import com.ebs.md.api.Rate;
import com.ebs.md.api.orderbook.BookEntryPositionOfDeleted;
import com.ebs.md.api.product.PairProduct;

/**
 * OBCRemove - OrderBookChange Entry Removed
 * 
 * @author asher
 */
public class OBCRemove
extends AbsOBChange
{
	// gened with Eclipse
	private static final long serialVersionUID = -6237341031835281175L;

	/**
	 * entryLifeTime. lifeTime of the quote, since available until interrupted (canceled).
	 * value in milliseconds
	 */
	protected long    entryLifeTime;
	/**
	 * wasInterrupted. 
	 * true  - if the trader interrupted(canceled) his quote(order).
	 * false - if it was consumed totally with deals. 
	 */
	protected boolean wasInterrupted = true;
	
	public OBCRemove(long timestamp, String quoteId, PairProduct pair,
			BookSide bookSide, String dealCode, String traderId, Rate rate,
			long availAmount, int obPosition, int obEnriesAtPosition
		  , long entryLifeTime, boolean wasInterrupted, String region, int firmId) {
		super(timestamp, quoteId, pair, bookSide, dealCode, traderId, rate, availAmount, obPosition, obEnriesAtPosition, region, firmId);
		this.entryLifeTime = entryLifeTime;
		this.wasInterrupted = wasInterrupted;
	}

	public OBCRemove(PairProduct pair, IDetailedBookEntry be, BookEntryPositionOfDeleted bep, int firmId
			, long entryLifeTime, boolean wasInterrupted) {
		super(pair, be, bep, firmId);
		this.entryLifeTime = entryLifeTime;
		this.wasInterrupted = wasInterrupted;
	}
	
	public long getEntryLifeTime() {
		return entryLifeTime;
	}
	public boolean wasInterrupted() {
		return wasInterrupted;
	}
	// using as standard "isXXX" so Esper will be able to refer 
	// (though "isWas" is not that best phrase...)
	public boolean isWasInterrupted() {
		return wasInterrupted;
	}

	public boolean isObPositionEmptyAfterRemoval() {
		return obEntriesAtPosition == 1;
	}

	public boolean isFromTopOfBook() {
		return obPosition == 1;
	}

	protected String additionalFields4toString() {
		return ", wasInterrupted=" + wasInterrupted
			 + ", entryLifeTime=" + entryLifeTime
		     ;
	}
	
}
